<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!-- 引入vue2的js文件 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.9/vue.js"></script>
</head>

<body>
    <div id="app">
        <p>count : {{count}}</p>
        <p>count的平方 : {{square}}</p>
        <button @click="count++">点击+1</button>
    </div>

    <script>
        new Vue({
            el: '#app',
            data: {
                count: 1
            },
            computed: {
                square() {
                    // 计算属性中的计算结果需要return返回
                    return this.count * this.count
                }
            }
        })
    </script>
</body>

</html>